package week5.day30;

import java.util.*;

/**
 * @Author fengzihao
 * @Date 2024-05-14 20:51
 */
public class CollectionPractice {
    public static void main(String[] args) {
        HashSet<Integer> redRandomNumbers = new HashSet<>();
        Random random = new Random();
        while (redRandomNumbers.size()<6){
            Integer number = random.nextInt(33) + 1;
            redRandomNumbers.add(number);
        }
        UnionLottoNumber unionLottoNumber = new UnionLottoNumber();
        Integer[] numbers = new Integer[6];
        Integer[] array = redRandomNumbers.toArray(numbers);
        unionLottoNumber.redNumber = Arrays.stream(array).mapToInt(Integer::intValue).toArray();
        Integer number = random.nextInt(16) + 1;
        unionLottoNumber.blueNumber = number;
        ArrayList<UnionLottoNumber> unionLottoNumberArrayList = new ArrayList<>();
        unionLottoNumberArrayList.add(unionLottoNumber);
        System.out.println("unionLottoNumberArrayList = " + unionLottoNumberArrayList);
    }
    public static <T> Collection<T> nonredundantCollection(Collection<T> collection){
        Collection<T> collection1 = new ArrayList<>();
        HashSet<T> hashSet = new HashSet<>();
        Iterator<T> iterator1 = collection.iterator();
        while (iterator1.hasNext()){
            T t = iterator1.next();
            hashSet.add(t);
        }
        Iterator<T> iterator2 = hashSet.iterator();
        while (iterator2.hasNext()){
            T t = iterator2.next();
            collection1.add(t);
        }
        return collection1;
    }
}
class UnionLottoNumber{
    int[] redNumber = new int[6];
    int blueNumber;

    @Override
    public String toString() {
        return "UnionLottoNumber{" +
                "redNumber=" + Arrays.toString(redNumber) +
                ", blueNumber=" + blueNumber +
                '}';
    }
}